//
//  DDAcountTool.m
//  DingDongXiChe
//
//  Created by wtjr on 2018/1/8.
//  Copyright © 2018年 xieyingze. All rights reserved.
//

#import "DDAcountTool.h"

#define DDAccountPath [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"account.archive"]

@implementation DDAcountTool

+ (void)saveAccount:(DDAccount *)account {
    [NSKeyedArchiver archiveRootObject:account toFile:DDAccountPath];
}

+ (DDAccount *)account {
    DDAccount *account = [NSKeyedUnarchiver unarchiveObjectWithFile:DDAccountPath];
    return account;
}

+ (BOOL)deleteAccount {
    return [[NSFileManager defaultManager] removeItemAtPath:DDAccountPath error:nil];
}

@end
